<?php
namespace models\repositories;
use Doctrine\ORM\EntityRepository;
use entities;
class AktivitasUserDokumenRepository extends EntityRepository {
	public function testIterate(){
		echo "<br>iterasi x";
	}
	public function findAllAsObject(){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('AktivitasUserDokumen')
		   ->from('models\entities\AktivitasUserDokumen', 'AktivitasUserDokumen')
		;
		
		$query = $qb->getQuery();
		return $query->getResult();
	}
	
	public function findByIdAsObject($id){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('AktivitasUserDokumen')
		   ->from('models\entities\AktivitasUserDokumen', 'AktivitasUserDokumen')		   
		   ->where('AktivitasUserDokumen.id = ?1')
		;
		
		$qb->setParameter(1, $id);
		$query = $qb->getQuery();
		return $query->getResult();
	}
	public function findByIdDokAsObject($idDok){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('AktivitasUserDokumen')
		   ->from('models\entities\AktivitasUserDokumen', 'AktivitasUserDokumen')		   
		   ->where('AktivitasUserDokumen.idDok = ?1')
		;
		
		$qb->setParameter(1, $idDok);
		$query = $qb->getQuery();
		return $query->getResult();
	}
	
	public function findByUserIdAsObject($userId){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('AktivitasUserDokumen')
		   ->from('models\entities\AktivitasUserDokumen', 'AktivitasUserDokumen')		   
		   ->where('AktivitasUserDokumen.userId = ?1')
		;
		
		$qb->setParameter(1, $userId);
		$query = $qb->getQuery();
		return $query->getResult();
	}

	public function findByJenisAktivitasAsObject($jenisAktivitas){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('AktivitasUserDokumen')
		   ->from('models\entities\AktivitasUserDokumen', 'AktivitasUserDokumen')		   
		   ->where('AktivitasUserDokumen.jenisAktivitas = ?1')
		;
		
		$qb->setParameter(1, $jenisAktivitas);
		$query = $qb->getQuery();
		return $query->getResult();
	}
}

